#-*- coding:UTF-8 -*-

import os.path

import handlers as handler

#from tornado.web import StaticFileHandler

from .handlers import StaticFileHandlerEx
from .props import (URL_PREFIX, APP_PREFIX, LOCAL_HTML_BASE, 
                    LOCAL_HTML_TEMP_BASE, LOCAL_STATIC_BASE, HTML_URL_BASE)
from ..config import PLATMGT_HOME, get_property


request_handlers = [(URL_PREFIX+'(/){0,1}$', handler.HomeHandler),\
                    (URL_PREFIX+APP_PREFIX+'(/){0,1}$', handler.HomeHandler),\
                    #(URL_PREFIX+APP_PREFIX+'/pages/login', handler.LoginHandler),\
                    #(URL_PREFIX+APP_PREFIX+'/pages/logout', handler.LogoutHandler),\
                    (URL_PREFIX+APP_PREFIX+'/pages/(.*)', handler.DynamicPageHandler),\
                    (URL_PREFIX+APP_PREFIX+'/(.*)', StaticFileHandlerEx, {'path': LOCAL_STATIC_BASE}),\
                    (URL_PREFIX+'/aj/(.*)', handler.AjaxRequestHandler),\
                    (URL_PREFIX+'/wt/ssh', handler.WebTerminalHandler),\
                    (URL_PREFIX+'/wt/terminal', handler.TerminalPageHandler),\
                    (URL_PREFIX+'/wt/wssize', handler.WebSSHSizeHandler),\
                    (URL_PREFIX+'/adminlte/(.*)', StaticFileHandlerEx, {'path': LOCAL_HTML_TEMP_BASE}),\
                    ('/(.*)', handler.NotFoundHandler),\
                    ]


web_settings={'static_path':os.path.join(PLATMGT_HOME,"templates"),
          'static_url_prefix':'/templates/',
          'template_path':os.path.join(PLATMGT_HOME,"templates"),
          'login_url': '%s/pages/login'%HTML_URL_BASE,
          'cookie_secret':'61oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=',
          'session_secret ':'3cdcb1f00803b6e78ab50b466a40b9977db396840c28307f428b25e2277f1bcc',
          "xsrf_cookies": False,
          'debug':True,
          'autoreload':False
          }
